var express = require('express');
var router = express.Router();
var db = require('../utils/db');

/* GET home page. */
router.get('/', function (req, res, next) {
    res.render('index', {title: 'Express'});
});

router.get('/getList', function (req, res, next) {
    res.send('{"data":"Hello HongBo"}');
});

router.get('/getDB', function (req, res, next) {
    let ressql = 'SELECT * FROM deploy_collection limit 10';
    db.queryAsync(ressql, function (err, result) {
        if (err) {
            console.log('error sql')
        }
        res.render('index', {title: 'Express', data: JSON.stringify(result, null, 2)});
    })
});

module.exports = router;
